using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace TurbaconPhone
{
    public abstract class State
    {
        
        #region Fields
        bool bInitialized = false;
        GestureType enabledGestures;

        #endregion

        #region Properties
        public GestureType EnabledGestures
        {
            get { return enabledGestures; }
            protected set
            {
                enabledGestures = value;                   
                TouchPanel.EnabledGestures = value;
            }
        }

        #endregion


        public virtual void ExitState()
        {
            bInitialized = false;
        }
        public virtual void EnterState()
        {
          //  EnabledGestures = GestureType.None;
        }

        public abstract void Draw(SpriteBatch spriteBatch);
        public virtual void Update(GameTime gametime)
        {
            if (!bInitialized)
            {
                EnterState();
                bInitialized = true;
            }
        }

        public virtual void HandleInput()
        {
            for (int i = 0; i < TurBacon.Input.Gestures.Count; i++)
            {
                GestureSample gesture = TurBacon.Input.Gestures[i];

                switch (gesture.GestureType)
                {
                    case GestureType.Hold:
                        HandleHold(gesture);
                        break;
                    case GestureType.Tap:
                        HandleTap(gesture);
                        break;
                    case GestureType.FreeDrag:
                        HandleFreeDrag(gesture);
                        break;
                    case GestureType.DoubleTap:
                        HandleDoubleTap(gesture);
                        break;
                    case GestureType.Flick:
                        HandleFlick(gesture);
                        break;
                    case GestureType.DragComplete:
                        HandleDragComplete(gesture);
                        break;
                }

            }
        }
        public virtual void HandleTap(GestureSample gesture){}
        public virtual void HandleFreeDrag(GestureSample gesture){}
        public virtual void HandleFlick(GestureSample gesture){}
        public virtual void HandleDoubleTap(GestureSample gesture){}
        public virtual void HandleDragComplete(GestureSample gesture){}
        public virtual void HandleHold(GestureSample gesture) { }
    }
}
